package com.itheima.zzyl.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.zzyl.mapper.NursingProjectMapper;
import com.itheima.zzyl.pojo.NursingProject;
import com.itheima.zzyl.pojo.PageResult;
import com.itheima.zzyl.pojo.Result;
import com.itheima.zzyl.service.NursingProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;

@Service("nursingProjectService")
public class NursingProjectServiceImpl implements NursingProjectService {
    @Autowired
    private NursingProjectMapper nursingProjectMapper;

    @Override
    public Result<PageResult<NursingProject>> list(Integer pageSize, Integer pageNumber) {
        PageHelper.startPage(pageSize, pageNumber);
        List<NursingProject> list = nursingProjectMapper.list();
        PageInfo<NursingProject> pageInfo = new PageInfo<>(list);
        PageResult<NursingProject> page = new PageResult<>();
        page.setRecords(pageInfo.getList());
        page.setPageSize(pageInfo.getPageSize());
        page.setTotal(pageInfo.getTotal());
        return Result.success(page);
    }

    @Override
    public NursingProject getById(Integer id) {
        return nursingProjectMapper.getById(id);
    }
}
